import { EaseChatClient } from "../initImSdk";
import { useMessageStore } from "@/store";
const messageStore = useMessageStore();
export const imReviceMessageListener = () => {
  /**
   * @description mountReviceMessageEventListener - 监听消息状态
   */
  const mountReviceMessageEventListener = () => {
    // 将消息存储到store中
    EaseChatClient.addEventHandler("messageListen", {
      onTextMessage: () => {
        console.log("收到文本消息");
      },
    });
  };
  /**
   * @description pushNewMessage - 接收的消息往store中push
   */
  const pushNewMessage = (message: unknown) => {
    messageStore.createNewMessage(message);
  };

  return {
    mountReviceMessageEventListener,
    pushNewMessage,
  };
};
